package action.grade;

import java.util.ArrayList;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import model.GradeRecord;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

import service.queryGradeService;

import com.opensymphony.xwork2.ActionSupport;

@Namespace("")
@Action(
	value="queryAllGrade",
	results={
			@Result(name="success",location="/WEB-INF/graderesult.jsp")
	}		
)
public class queryAllGrade extends ActionSupport{
	
	public String execute() throws Exception{
        ArrayList<GradeRecord> record=new  ArrayList<GradeRecord>();
		HttpServletRequest request=ServletActionContext.getRequest();
		ServletContext application=request.getServletContext();
		String user_id=(String) request.getSession().getAttribute("user_id");
		String schoolyear=(String) application.getAttribute("schoolyear");
		queryGradeService qgs=new queryGradeService();
		record=qgs.queryAllGrade(user_id,schoolyear);
		request.setAttribute("GradeRecordList", record);
		return SUCCESS;
	}

}
